package com.klun.aop.method;

/* 定义一个MethodMonitor类用来记录Method执行时间 */
public class MethodMonitor {
    /*开始时间*/
    private long start;
    private String method;

    public MethodMonitor(String method) {
        System.out.println(method+":****当前线程::"+Thread.currentThread().getName());
        this.method = method;
        this.start = System.currentTimeMillis();
    }

    public void log() {
        System.out.println(method+":****当前线程::"+Thread.currentThread().getName());
        long elapsedTime = System.currentTimeMillis() - start;
        System.out.println("Method: " + method + ", execution time: " + elapsedTime + " milliseconds.");
    }
}
